home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3006 / 3006.xpi / chrome / dwhelper.jar / content / mp3tunes / mp3tunes.xml < prev    next >
Extensible Markup Language  |  2010-01-15  |  16KB  |  578 lines

  1. <?xml version="1.0"?>
  2. <!-- *****************************************************************************
  3.  *            Copyright (c) 2006-2007 Michel Gutierrez. All Rights Reserved.
  4.  ****************************************************************************** -->
  5. <!DOCTYPE bindings SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
  6.  
  7. <bindings xmlns="http://www.mozilla.org/xbl"
  8.     xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  9.     xmlns:html="http://www.w3.org/1999/xhtml"
  10.     xmlns:xbl="http://www.mozilla.org/xbl">
  11.  
  12.     <binding id="MP3TunesConfig" extends="../widgets.xml#widget">
  13.  
  14.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  15.             <vbox flex="1">
  16.                 <spacer flex="1"/>
  17.                 <grid flex="1">
  18.                     <columns>
  19.                         <column/>
  20.                         <column flex="1"/>
  21.                     </columns>
  22.                     <rows>
  23.                         <row anonid="xStatusRow" hidden="true">
  24.                             <label value="&mp3tunes.pref.last-check;"/>
  25.                             <description anonid="xStatus" class="feature-descr" style="max-height: 20px; overflow: auto;"/>
  26.                         </row>
  27.                         <row align="center">
  28.                             <label value="&mp3tunes.pref.username;"/>
  29.                             <textbox anonid="xUsername"/>
  30.                         </row>
  31.                         <row align="center">
  32.                             <label value="&mp3tunes.pref.password;"/>
  33.                             <DHPassword anonid="xPassword"/>
  34.                         </row>
  35.                         <row align="center">
  36.                             <label value="&mp3tunes.pref.phonenumber;"/>
  37.                             <hbox align="center">
  38.                                 <textbox anonid="xPhonenumber"/>
  39.                                 <label value="&mp3tunes.pref.phonenumber-sample;" style="font-style: italic;"/>
  40.                             </hbox>
  41.                         </row>
  42.                         <row>
  43.                             <spacer/>
  44.                             <description class="feature-descr">&mp3tunes.pref.phonenumber.description;</description>
  45.                         </row>
  46.                         <row>
  47.                             <spacer/>
  48.                             <hbox>
  49.                                 <spacer flex="1"/>
  50.                                 <button label="&label.privacy-policy;" oncommand="this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.privacyPolicy()"/>
  51.                             </hbox>
  52.                         </row>
  53.                         <row>
  54.                             <spacer/>
  55.                             <hbox align="center">
  56.                                 <spacer flex="1"/>
  57.                                 <label value="&mp3tunes.pref.on-send-mobile;"/>
  58.                                 <menulist anonid="xOnMobile">
  59.                                     <menupopup>
  60.                                         <menuitem label="&mp3tunes.pref.on-send.video;" value="video"/>
  61.                                         <menuitem label="&mp3tunes.pref.on-send.audio;" value="audio"/>
  62.                                         <menuitem label="&mp3tunes.pref.on-send.ask;" value="ask"/>
  63.                                     </menupopup>
  64.                                 </menulist>
  65.                             </hbox>
  66.                         </row>
  67.                         <row>
  68.                             <spacer/>
  69.                             <hbox align="center">
  70.                                 <spacer flex="1"/>
  71.                                 <label value="&mp3tunes.pref.on-send-locker;"/>
  72.                                 <menulist anonid="xOnLocker">
  73.                                     <menupopup>
  74.                                         <menuitem label="&mp3tunes.pref.on-send.video;" value="video"/>
  75.                                         <menuitem label="&mp3tunes.pref.on-send.audio;" value="audio"/>
  76.                                         <menuitem label="&mp3tunes.pref.on-send.ask;" value="ask"/>
  77.                                     </menupopup>
  78.                                 </menulist>
  79.                             </hbox>
  80.                         </row>
  81.                         
  82.                     </rows>
  83.                 </grid>
  84.                 <spacer flex="1"/>
  85.                 <hbox>
  86.                     <button anonid="xCreateBut" label="&mp3tunes.pref.create-account;" oncommand="this.parentNode.parentNode.parentNode.createAccount()"/>
  87.                     <button anonid="xUpgradeBut" label="&mp3tunes.pref.upgrade-account;" oncommand="this.parentNode.parentNode.parentNode.upgradeAccount()" hidden="true"/>
  88.                     <button anonid="xOpenLockerBut" label="&mp3tunes.label.open-locker;" oncommand="this.parentNode.parentNode.parentNode.openLocker()" hidden="true"/>
  89.                     <spacer flex="1"/>
  90.                     <button label="&mp3tunes.pref.check-account;" oncommand="this.parentNode.parentNode.parentNode.checkAccount()"/>
  91.                 </hbox>
  92.                 <spacer flex="1"/>
  93.             </vbox>
  94.             <children style="display: none;"/>
  95.         </xbl:content>
  96.  
  97.         <implementation>
  98.  
  99.             <constructor>
  100.                 <![CDATA[
  101. this.mtMgr=Components.classes["@downloadhelper.net/mp3tunes-manager;1"]
  102.     .getService(Components.interfaces.dhIMP3Tunes);
  103. this.setAttribute("onsyncfrompreference","this.onSyncFromPreference(event)");
  104. this.setAttribute("onsynctopreference","this.onSyncToPreference(event)");
  105. var prefService=Components.classes["@mozilla.org/preferences-service;1"]
  106.                                    .getService(Components.interfaces.nsIPrefService);
  107. this.pref=prefService.getBranch("dwhelper.mp3tunes.");
  108. setTimeout(function(_this) { _this.updateStatus(); },0,this);
  109.                 ]]>
  110.             </constructor>
  111.  
  112.             <method name="init">
  113.                 <body>
  114.                 <![CDATA[
  115.                 ]]>
  116.                 </body>
  117.             </method>
  118.  
  119.  
  120.             <method name="onSyncFromPreference">
  121.                 <parameter name="event"/>
  122.                 <body>
  123.                 <![CDATA[
  124.  
  125. this.xUsername.value=this.pref.getCharPref("username");
  126. setTimeout(function(_this) {
  127.     var password=_this.util.getPassword("mp3tunes");
  128.     _this.xPassword.value=(password!=null)?password:"";
  129. },0,this);
  130. this.xPhonenumber.value=this.pref.getCharPref("phonenumber");
  131. this.xOnMobile.value=this.pref.getCharPref("upload.mobile");
  132. this.xOnLocker.value=this.pref.getCharPref("upload.locker");
  133.                 ]]>
  134.                 </body>
  135.             </method>
  136.  
  137.             <method name="onSyncToPreference">
  138.                 <parameter name="event"/>
  139.                 <body>
  140.                 <![CDATA[
  141. this.pref.setCharPref("username",this.xUsername.value);
  142. if(this.xPassword.valueSet)
  143.     this.util.setPassword("mp3tunes",this.xPassword.value);
  144. this.pref.setCharPref("phonenumber",this.xPhonenumber.value);
  145. this.pref.setCharPref("upload.mobile",this.xOnMobile.value);
  146. this.pref.setCharPref("upload.locker",this.xOnLocker.value);
  147.                 ]]>
  148.                 </body>
  149.             </method>
  150.  
  151.             <method name="createAccount">
  152.                 <body>
  153.                 <![CDATA[
  154. var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  155.                             .getService(Components.interfaces.nsIWindowMediator);
  156. var w = wm.getMostRecentWindow("navigator:browser");
  157. var data={};
  158. w.openDialog("chrome://dwhelper/content/mp3tunes/create-account.xul",
  159.     "mp3tunes-create-account",
  160.     "chrome,centerscreen,modal,resizable=yes",data);
  161. if(data.accountData) {
  162.     this.xUsername.value=data.accountData.username;
  163.     this.xPassword.value=data.accountData.password;
  164.     this.updateStatus();
  165.     this.util.alertWarning(this.util.getText("mp3tunes.message.account-created"));
  166. }    
  167.                 ]]>
  168.                 </body>
  169.             </method>
  170.  
  171.             <method name="upgradeAccount">
  172.                 <body>
  173.                 <![CDATA[
  174. var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  175.                             .getService(Components.interfaces.nsIWindowMediator);
  176. var w = wm.getMostRecentWindow("navigator:browser");
  177. w.open("http://www.downloadhelper.net/mp3tunes-upgrade.php");
  178.                 ]]>
  179.                 </body>
  180.             </method>
  181.  
  182.             <method name="checkAccount">
  183.                 <body>
  184.                 <![CDATA[
  185. function AccountStatusObserver(client) {
  186.     this.client=client;
  187. }
  188. AccountStatusObserver.prototype={
  189.     observe: function(subject,topic,data) {
  190.         if(topic=="mp3tunes-account-status") {
  191.             this.client.updateStatus();
  192.         }
  193.     }
  194. }
  195. try {
  196.     while(this.xStatus.firstChild)
  197.         this.xStatus.removeChild(this.xStatus.firstChild);
  198.     this.xStatus.appendChild(document.createTextNode(this.util.getText("mp3tunes.text.checking-account")));
  199.     this.disableAll(true);
  200.     this.mtMgr.accountStatus(
  201.         this.xUsername.value,
  202.         this.xPassword.value,
  203.         new AccountStatusObserver(this)
  204.     );
  205. } catch(e) {
  206. }
  207.                 ]]>
  208.                 </body>
  209.             </method>
  210.  
  211.             <method name="updateStatus">
  212.                 <body>
  213.                 <![CDATA[
  214. this.disableAll(false);
  215. var status="unchecked";
  216. try {
  217.     status=this.pref.getCharPref("last-status");
  218. } catch(e) {}
  219. this.xStatusRow.setAttribute("hidden","true");
  220. var lastStatusText=null;
  221. switch(status) {
  222.     case "unchecked":
  223.         this.xCreateBut.setAttribute("hidden","false");
  224.         this.xUpgradeBut.setAttribute("hidden","true");
  225.         this.xOpenLockerBut.setAttribute("hidden","true");
  226.         break;
  227.     case "free":
  228.         this.xCreateBut.setAttribute("hidden","true");
  229.         this.xUpgradeBut.setAttribute("hidden","false");
  230.         this.xOpenLockerBut.setAttribute("hidden","false");
  231.         lastStatusText=this.util.getText("mp3tunes.message.free-account-verified");
  232.         break;
  233.     case "premium":
  234.         this.xCreateBut.setAttribute("hidden","true");
  235.         this.xUpgradeBut.setAttribute("hidden","true");
  236.         this.xOpenLockerBut.setAttribute("hidden","false");
  237.         lastStatusText=this.util.getText("mp3tunes.message.premium-account-verified");
  238.         break;
  239.     default:
  240.         this.xCreateBut.setAttribute("hidden","false");
  241.         this.xUpgradeBut.setAttribute("hidden","true");
  242.         this.xOpenLockerBut.setAttribute("hidden","true");
  243.         lastStatusText=status;
  244. }
  245. if(lastStatusText) {
  246.     while(this.xStatus.firstChild)
  247.         this.xStatus.removeChild(this.xStatus.firstChild);
  248.     this.xStatus.appendChild(document.createTextNode(lastStatusText));
  249.     this.xStatusRow.setAttribute("hidden","false");
  250. }
  251.                 ]]>
  252.                 </body>
  253.             </method>
  254.  
  255.             <method name="disableAll">
  256.                 <parameter name="disable"/>
  257.                 <body>
  258.                 <![CDATA[
  259. var tbs=["xUsername","xPassword","xPhonenumber"];
  260. for(var i in tbs) {
  261.     this[tbs[i]].disabled=disable;
  262. }
  263.                 ]]>
  264.                 </body>
  265.             </method>
  266.  
  267.             <method name="privacyPolicy">
  268.                 <body>
  269.                 <![CDATA[
  270. window.open("http://www.mp3tunes.com/privacy?partner=5418414535");
  271.                 ]]>
  272.                 </body>
  273.             </method>
  274.  
  275.             <method name="openLocker">
  276.                 <body>
  277.                 <![CDATA[
  278. function AuthObserver(client) {
  279.     this.client=client;
  280. }
  281. AuthObserver.prototype={
  282.     observe: function(subject,topic,data) {
  283.         var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  284.                                     .getService(Components.interfaces.nsIWindowMediator);
  285.         var window = wm.getMostRecentWindow("navigator:browser");
  286.         if(topic=="mp3tunes-auth-succeeded") {
  287.             window.open("http://www.mp3tunes.com/player/");
  288.         } else {
  289.             this.client.util.alertError(this.client.util.getText("mp3tunes.error.no-login-check-credentials"));
  290.         }
  291.     }
  292. }
  293. this.mtMgr.authenticate(this.xUsername.value,this.xPassword.value,new AuthObserver(this));
  294.                 ]]>
  295.                 </body>
  296.             </method>
  297.  
  298.                         
  299.         </implementation>
  300.                 
  301.     </binding>
  302.  
  303.     <binding id="MP3TunesCreateAccount" extends="../widgets.xml#widget">
  304.  
  305.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  306.             <grid flex="1">
  307.                 <columns>
  308.                     <column/>
  309.                     <column/>
  310.                 </columns>
  311.                 <rows>
  312.                     <row align="center">
  313.                         <label value="&mp3tunes.pref.username;"/>
  314.                         <textbox anonid="xUsername"/>
  315.                     </row>
  316.                     <row align="center">
  317.                         <label value="&mp3tunes.pref.password;"/>
  318.                         <textbox anonid="xPassword" type="password"/>
  319.                     </row>
  320.                     <row align="center">
  321.                         <label value="&mp3tunes.pref.password-repeat;"/>
  322.                         <textbox anonid="xPassword2" type="password"/>
  323.                     </row>
  324.                     <row align="center">
  325.                         <label value="&mp3tunes.pref.firstname;"/>
  326.                         <textbox anonid="xFirstname"/>
  327.                     </row>
  328.                     <row align="center">
  329.                         <label value="&mp3tunes.pref.lastname;"/>
  330.                         <textbox anonid="xLastname"/>
  331.                     </row>
  332.                 </rows>
  333.             </grid>
  334.             <children style="display: none;"/>
  335.         </xbl:content>
  336.  
  337.         <implementation>
  338.  
  339.             <constructor>
  340.                 <![CDATA[
  341. if(this.hasAttribute("dialog"))
  342.     this.dialog=document.getElementById(this.getAttribute("dialog"));
  343. this.mtMgr=Components.classes["@downloadhelper.net/mp3tunes-manager;1"]
  344.     .getService(Components.interfaces.dhIMP3Tunes);
  345.                 ]]>
  346.             </constructor>
  347.  
  348.             <destructor>
  349.                 <![CDATA[
  350.                 ]]>
  351.             </destructor>
  352.  
  353.             <method name="validate">
  354.                 <body>
  355.                 <![CDATA[
  356. if(!/^[0-9a-zA-Z][-.\w]*[0-9a-zA-Z]*@[0-9a-zA-Z][-\w][^_]*[0-9a-zA-Z]\.+[a-zA-Z]{2,9}$/.test(this.xUsername.value)) {
  357.     this.util.alertError(this.util.getText("mp3tunes.error.username-invalid"));
  358.     this.selectField(this.xUsername);
  359.     return null;
  360. }
  361. if(this.xPassword.value!=this.xPassword2.value) {
  362.     this.util.alertError(this.util.getText("mp3tunes.error.unmatching-passwords"));
  363.     this.selectField(this.xPassword);
  364.     return null;
  365. }
  366. if(this.xPassword.value.length==0) {
  367.     this.util.alertError(this.util.getText("mp3tunes.error.empty-field"));
  368.     this.selectField(this.xPassword);
  369.     return null;
  370. }
  371. if(this.xFirstname.value.length==0) {
  372.     this.util.alertError(this.util.getText("mp3tunes.error.empty-field"));
  373.     this.selectField(this.xFirstname);
  374.     return null;
  375. }
  376. if(this.xLastname.value.length==0) {
  377.     this.util.alertError(this.util.getText("mp3tunes.error.empty-field"));
  378.     this.selectField(this.xLastname);
  379.     return null;
  380. }
  381.  
  382. this.disableAll(true);
  383.  
  384. function CreateAccountObserver(client) {
  385.     this.client=client;
  386. }
  387.  
  388. CreateAccountObserver.prototype={
  389.     observe: function(subject,topic,data) {
  390.         if(topic=="mp3tunes-create-account-succeeded") {
  391.             this.client.serverResponse(true,null);
  392.         }
  393.         if(topic=="mp3tunes-create-account-failed") {
  394.             this.client.serverResponse(false,data);
  395.         }
  396.     }
  397. }
  398. try {
  399.     this.mtMgr.createAccount(
  400.         this.xUsername.value,
  401.         this.xPassword.value,
  402.         this.xFirstname.value,
  403.         this.xLastname.value,
  404.         new CreateAccountObserver(this)
  405.     );
  406. } catch(e) {
  407. }
  408.                 ]]>
  409.                 </body>
  410.             </method>
  411.             
  412.             <method name="selectField">
  413.                 <parameter name="field"/>
  414.                 <body>
  415.                 <![CDATA[
  416. field.focus();
  417. field.select();
  418.                 ]]>
  419.                 </body>
  420.             </method>
  421.  
  422.             <method name="disableAll">
  423.                 <parameter name="disable"/>
  424.                 <body>
  425.                 <![CDATA[
  426. if(this.dialog) {
  427.     this.dialog.getButton("accept").setAttribute("hidden",""+disable);
  428.     this.dialog.getButton("cancel").setAttribute("hidden",""+disable);
  429. }
  430. var tbs=["xUsername","xPassword","xPassword2","xFirstname","xLastname"];
  431. for(var i in tbs) {
  432.     this[tbs[i]].disabled=disable;
  433. }
  434.                 ]]>
  435.                 </body>
  436.             </method>
  437.  
  438.             <method name="serverResponse">
  439.                 <parameter name="status"/>
  440.                 <parameter name="message"/>
  441.                 <body>
  442.                 <![CDATA[
  443. this.disableAll(false);
  444. if(!status) {
  445.     this.util.alertError(message);
  446. } else {
  447.     if(this.getAttribute("oncreatedaccount")) {
  448.         try {
  449.             var f=new Function("data",this.getAttribute("oncreatedaccount"));
  450.             f.call(this,{
  451.                 username: this.xUsername.value,
  452.                 password: this.xPassword.value,
  453.                 firstname: this.xFirstname.value,
  454.                 lastname: this.xLastname
  455.             });
  456.         } catch(e) { 
  457.         }
  458.     }
  459. }
  460.                 ]]>
  461.                 </body>
  462.             </method>
  463.  
  464.             
  465.         </implementation>
  466.         
  467.         <handlers>
  468.             
  469.             <!-- 
  470.             <handler event="DOMAttrModified">
  471.                 <![CDATA[
  472.                 ]]>
  473.             </handler>
  474.              -->
  475.     
  476.         </handlers>
  477.  
  478.     </binding>
  479.  
  480.     <binding id="MP3TunesTitle" extends="../widgets.xml#widget">
  481.  
  482.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  483.             <grid flex="1">
  484.                 <columns>
  485.                     <column/>
  486.                     <column flex="1"/>
  487.                 </columns>
  488.                 <rows>
  489.                     <row align="center">
  490.                         <label value="&mp3tunes.title.artist-name;" class="mandatory"/>
  491.                         <textbox anonid="xArtistName"/>
  492.                     </row>
  493.                     <row align="center">
  494.                         <label value="&mp3tunes.title.album-title;"/>
  495.                         <textbox anonid="xAlbumTitle"/>
  496.                     </row>
  497.                     <row align="center">
  498.                         <label value="&mp3tunes.title.track-title;" class="mandatory"/>
  499.                         <textbox anonid="xTrackTitle"/>
  500.                     </row>
  501.                     <row align="center">
  502.                         <label value="&mp3tunes.title.track-number;"/>
  503.                         <hbox align="center">
  504.                             <textbox anonid="xTrackNumber"/>
  505.                             <spacer flex="1"/>
  506.                             <label value="&mp3tunes.title.year;"/>
  507.                             <textbox anonid="xYear"/>
  508.                         </hbox>
  509.                     </row>                    
  510.                 </rows>
  511.             </grid>
  512.             <children style="display: none;"/>
  513.         </xbl:content>
  514.  
  515.         <implementation>
  516.  
  517.             <constructor>
  518.                 <![CDATA[
  519.                 ]]>
  520.             </constructor>
  521.  
  522.             <destructor>
  523.                 <![CDATA[
  524.                 ]]>
  525.             </destructor>
  526.  
  527.             <method name="validate">
  528.                 <parameter name="entry"/>
  529.                 <body>
  530.                 <![CDATA[
  531. if(this.xArtistName.value.length==0) {
  532.     this.util.alertError(this.util.getText("mp3tunes.error.empty-field"));
  533.     this.selectField(this.xArtistName);
  534.     return false;
  535. }
  536. if(this.xTrackTitle.value.length==0) {
  537.     this.util.alertError(this.util.getText("mp3tunes.error.empty-field"));
  538.     this.selectField(this.xTrackTitle);
  539.     return false;
  540. }
  541. this.util.setPropsString(entry,"mp3tunes-artist-name",this.xArtistName.value);
  542. this.util.setPropsString(entry,"mp3tunes-album-title",this.xAlbumTitle.value);
  543. this.util.setPropsString(entry,"mp3tunes-track-title",this.xTrackTitle.value);
  544. this.util.setPropsString(entry,"mp3tunes-track-number",this.xTrackNumber.value);
  545. this.util.setPropsString(entry,"mp3tunes-year",this.xYear.value);
  546. return true;
  547.                 ]]>
  548.                 </body>
  549.             </method>
  550.             
  551.             <method name="selectField">
  552.                 <parameter name="field"/>
  553.                 <body>
  554.                 <![CDATA[
  555. field.focus();
  556. field.select();
  557.                 ]]>
  558.                 </body>
  559.             </method>
  560.  
  561.         </implementation>
  562.         
  563.         <handlers>
  564.             
  565.             <!-- 
  566.             <handler event="DOMAttrModified">
  567.                 <![CDATA[
  568.                 ]]>
  569.             </handler>
  570.              -->
  571.     
  572.         </handlers>
  573.  
  574.     </binding>
  575.  
  576.  
  577. </bindings>
  578.